var List = new Class.create();

List.prototype = {
    page:0,
    url:"",
    data:{},
    list:[],
    noMoreData:false,
    cbFunction:undefined,
    animateFunc:undefined,
    lastNotEmptyData:[],
    initialize:function(){
        this.data["page"] = this.page
    }
    ,getList:function () {
        var _this = this;

        if (_this.noMoreData) {
            showToast("没有更多数据了")
            _this.cbFunction(_this.list);
        }else {
            _this.data.page = this.page
            if (_this.animateFunc !== undefined) {
                _this.animateFunc()
            }
            apiGet(this.url,this.data,function (res) {
                if (_this.lastNotEmptyData === res.d) {
                    return;
                }
                if (res.d.length === 0) {
                    showToast("没有更多数据了");
                    _this.noMoreData =true;
                    _this.cbFunction(_this.list);
                }else {
                    _this.lastNotEmptyData = res.d;
                    var orgList = _this.list
                    _this.list = orgList.concat(res.d);
                    _this.cbFunction(_this.list);
                    _this.page++;
                }
            });
        }
        return this;
    }
    ,reload:function(){
        this.page = 0;
        this.list = [];
        this.noMoreData = false;
        this.getList();
        return this;
    }

    ,setUrl:function(url){
        this.url = url
        return this;
    }
    ,setData:function(data){
        this.data = data
        this.data.page = this.page
        return this;
    }
    ,setCbFunc:function(func){
        this.cbFunction = func
        return this;
    }
    ,setAnimateFunc:function (func) {
        this.animateFunc = func
        return this;
    }


}